/** 
* Project Name:lg_service 
* File Name:SecurityNativeChannelService.java 
* Package Name:com.wl.api.service.business.impl 
* Date:2018年5月7日下午10:34:38 
* Copyright (c) 2018, lanls All Rights Reserved. 
* 
*/
package com.wl.api.service.system.impl;

import static com.wl.api.common.utils.PageInfo.transformPage;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.wl.api.common.utils.PageInfo;
import com.wl.api.dto.system.SecurityNativeChannelDTO;
import com.wl.api.mapper.system.SecurityNativeChannelMapper;
import com.wl.api.model.system.SecurityNativeChannel;
import com.wl.api.service.system.ISecurityNativeChannelService;

/**
 * ClassName: SecurityNativeChannelService <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2018年5月7日 下午10:34:38 <br/>
 * 
 * @author lanls
 * @version
 * @since JDK 1.6
 */
@Service
public class SecurityNativeChannelService extends ServiceImpl<SecurityNativeChannelMapper, SecurityNativeChannel>
		implements ISecurityNativeChannelService {

	/**
	 * TODO 简单描述该方法的实现功能（可选）.
	 * 
	 * @see com.wl.api.service.system.ISecurityNativeChannelService#selectByDynamic(com.wl.api.dto.system.SecurityNativeChannelDTO)
	 */
	@Override
	public PageInfo<SecurityNativeChannelDTO> selectByDynamicParameter(SecurityNativeChannelDTO param) {

		/**
		 * 动态参数查询逻辑在此处使用Wrapper添加
		 */
		Wrapper<SecurityNativeChannel> wrapper = new EntityWrapper<SecurityNativeChannel>().where(" 1=1 ");

		if (StringUtils.isNotBlank(param.getName())) {
			wrapper.like("name", param.getName());
		}

		if (null != param.getAreaId()) {
			wrapper.andNewSimple("area_id", param.getAreaId());
		}

		if (null != param.getIsPickup()) {
			wrapper.andNewSimple("is_pickup", param.getIsPickup());
		}

		if (null != param.getIsSelfSend()) {
			wrapper.andNewSimple("is_self_send", param.getIsSelfSend());
		}

		if (null != param.getStatus()) {
			wrapper.andNewSimple("status", param.getStatus());
		}

		if (null != param.getType()) {
			wrapper.andNewSimple("type", param.getType());
		}

		Page<SecurityNativeChannel> page = selectPage(new Page<>(param.getPage(), param.getPageSize(), "id", true),
				wrapper);
		PageInfo<SecurityNativeChannelDTO> pageInfo = transformPage(SecurityNativeChannelDTO.class, page);

		return pageInfo;
	}
}
